{% csrf_token %}
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="关闭">
            <span aria-hidden="true">×</span>
        </button>
        <h4 class="modal-title">设置用户为离职状态</h4>
    </div>
    <div class="modal-body">
        <p>是否要将用户 <span style="color: red">{{ user_profile_obj.name }}</span> 设置为离职状态</p>
    </div>
    <div class="modal-footer">
        <button type="button" id="button_set_departure_save" class="btn btn-primary margin-top-5">确定</button>
    </div>
</div>

<script>
    (function ($) {
        $("#button_set_departure_save").on('click', function () {
            var csrfmiddlewaretoken = $('input[name="csrfmiddlewaretoken"]').val();
            var data = "csrfmiddlewaretoken=" + csrfmiddlewaretoken;
            var url = 'set_departure/{{ user_profile_obj.id }}/';
            $.post(url, data, function (result) {
                if(!result['status']){
                    toastr['error'](result['message']);

                }else{
                    toastr['success'](result['message']);

                    setTimeout(function () {
                        location.reload()
                    }, 1000);

                }
            }, 'json')

        })
    })(jQuery)
</script>